{% extends "base.html" %}

{% block content %}
<div class="row mb-4">
    <div class="col-12">
        <h2>处理结果历史</h2>
    </div>
</div>

{% for batch in results %}
<div class="card mb-4">
    <div class="card-header">
        <div class="d-flex justify-content-between align-items-center">
            <h5 class="mb-0">批次: {{ batch.timestamp }}</h5>
            <span class="badge bg-primary">{{ batch.results|length }} 张图片</span>
        </div>
    </div>
    <div class="card-body">
        <div class="row">
            <div class="col-md-3">
                <h6>处理配置</h6>
                <ul class="list-unstyled">
                    <li>质量阈值: {{ batch.config.quality_threshold }}</li>
                    <li>人脸比例: {{ batch.config.face_ratio_range[0] }} - {{ batch.config.face_ratio_range[1] }}</li>
                    <li>偏航角范围: {{ batch.config.yaw_range[0] }}° - {{ batch.config.yaw_range[1] }}°</li>
                    <li>俯仰角范围: {{ batch.config.pitch_range[0] }}° - {{ batch.config.pitch_range[1] }}°</li>
                </ul>
            </div>
            <div class="col-md-9">
                <div class="row">
                    {% for result in batch.results %}
                    <div class="col-md-4 mb-3">
                        <div class="card">
                            <img src="{{ url_for('static', filename='results/' + batch.timestamp + '/images/normalized_' + result.filename) }}" 
                                 class="card-img-top" alt="{{ result.filename }}">
                            <div class="card-body p-2">
                                <p class="card-text small mb-1">
                                    <span class="text-muted">聚类ID:</span> {{ result.cluster }}
                                </p>
                                <p class="card-text small mb-0">
                                    <span class="text-muted">人脸比例:</span> 
                                    {{ "%.1f"|format(result.analysis.face_ratio * 100) }}%
                                </p>
                            </div>
                        </div>
                    </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endfor %}
{% endblock %} 